# @author Paul T.
module Calcula

  # All valid tree expression must be childrens of this class and should be
  # placed under the module `Calcula::Exprs`
  #
  # @see Calcula::Exprs
  # @abstract
  # @author Paul T.
  class Expr

    # Converts the expression to a string. If the form is `:src`, then the
    # resulting string should resemble as much as its source code as possible.
    # If the form is `:tree`, the result string should resemble in a Lisp like
    # form. If the form is `:ruby`, the result should be Ruby code that does the
    # same thing. Otherwise, `nil` should be returned.
    #
    # @param form [Optional, Symbol] The type of format being converted into
    # @return [String, nil] A string that resembles the specify form
    def to_s(form: :src)
      case form
      when :src then
        ""
      when :tree then
        "()"
      when :ruby then
        ""
      else
        nil
      end
    end

    # Returns the child nodes as a list. Child nodes must be transversible
    # (hence also expressions).
    #
    # @return [Array<Calcula::Expr>] A list of transversible child nodes
    def children
      []
    end
  end
end
